from selenium import webdriver
import time

if __name__ == '__main__':
    path = "chromedriver.exe"
    liu = webdriver.Chrome(path)
    url = "https://www.baidu.com/"
    liu.get(url)
    button = liu.find_element_by_id("kw")
    time.sleep(2)
    button.send_keys("奥里给")
    time.sleep(2)
    button = liu.find_element_by_id("su")
    button.click()
    time.sleep(2)
    hua = "document.documentElement.scrollTop=100000"
    liu.execute_script(hua)
    time.sleep(2)
    xia = liu.find_element_by_xpath("//a[@class='n']")
    xia.click()
    time.sleep(2)
    liu.back()
    time.sleep(2)
    liu.forward()
    with open("aa.html", "w", encoding="utf-8")as fp:
        fp.write(liu.page_source)
    liu.quit()
    pass
